

<h1>Listing submissions</h1>
<% if isadmin? %>
<%= link_to 'Back to Admin Tools', admin_pages_path %>
<%end%>

<script>
	$(document).ready(function(){
		$("#reset").bind("click", function (){
			$("#search").val("");
		});
	
		var rowNum = 0;
		$(".subRow").each(function() {
			if(rowNum % 2 == 0) {
				$(this).addClass("odd");
			}
			else {
				$(this).addClass("even");
			}
			rowNum++;
		});
	});
</script>


<%= render :partial => 'searchform' %>

<% if @submissions.length > 0 %>
<table class = "datagrid">
  <tr>
    <th> Common Name </th>
	<th> Submitter </th>
	<th> Location </th>	 
	<th> Region </th>	
    <th> Submission Date</th> 
	<th> Sighting Date</th>
	<th> Media </th>
	<th> Status </th>
	<th> Category of Acceptance </th>
    <!-- <th>User</th> -->
    <!-- <th>Sub fname</th>
    <!-- <th>Sub lname</th> -->
	<!-- <th>Num of birds</th> -->
    <!-- <th>Age</th> -->
    <!-- <th>Sex</th> -->
    <!-- <th>Plumage</th> -->   
    <!-- <th>Habitat</th> -->
    <!-- <th>Coobservers</th> -->
    <!-- <th>Length of obs</th> -->
    <!-- <th>Distance from</th> -->
    <!-- <th>Distinguished char</th> -->
    <!-- <th>Prev bird exp</th> -->
    <!-- <th>Optical equipment</th> -->
    <!-- <th>References</th> -->
    <!-- <th>Sub recall</th> -->
    <!-- <th>Guide use</th> -->
    <!-- <th>Unusual</th> -->
    <!-- <th>Notes</th> -->
    <!--  <th>Admin notes</th> -->
	<!-- <th>Working notes</th> -->
	
    <% if (isadmin? || isreviewer?) %>
	<th>Rounds</th> 
	<% end %>
    <th>Date accepted</th>
    <% if (isadmin? || isreviewer?) %>
	<th>Date votable</th>
	<% end %>    
   
	<th></th>
    
  </tr>

<% @submissions.each do |submission| %>
  <tr class="subRow">
	<td><%= submission.bird.common_name %>
		<% if submission.bird_id == 31 %>
		(<%= submission.common_name %>)
		<% end %></td>
	<td><%= link_to_if(isadmin?, submission.user.first_name+" "+submission.user.last_name, submission.user){submission.user.first_name+" "+submission.user.last_name} %></td>
	<td><%= submission.location %></td>
	<td><%= submission.region %></td>
	<td><%= submission.created_on.strftime("%m/%d/%y  %I:%M%p") if submission.created_on %></td>
	<td><%= submission.sight_date_time.strftime("%m/%d/%y  %I:%M%p") if submission.sight_date_time %></td>
	<td><%= submission.media %></td>
	<td><%= submission.status.humanize if submission.status %></td>
	<td><%= submission.s_degree %></td>	
    <% if (isadmin? || isreviewer?) %>
	<td><%= submission.rounds %></td>
	<% end %>
    <td><%= submission.date_accepted.strftime("%m/%d/%y  %I:%M%p") if submission.date_accepted %></td>
    <% if (isadmin? || isreviewer?) %>
	<td><%= submission.date_votable.strftime("%m/%d/%y") if submission.date_votable %></td>
	<% end %>
    <!-- <td><%= submission.user_id %></td> -->    
    <!-- <td><%= submission.user.last_name %></td> -->    
    <!-- <td><%= submission.num_of_birds %></td> -->
    <!-- <td><%= submission.age %></td>
    <!-- <td><%= submission.sex %></td> -->
    <!-- <td><%= submission.plumage %></td> -->    
    <!--  <td><%= submission.habitat %></td>
    <!-- <td><%= submission.coobservers %></td> -->
    <!-- <td><%= submission.length_of_obs %></td> -->
    <!-- <td><%= submission.distance_from %></td> -->
    <!-- <td><%= submission.distinguished_char %></td> -->
    <!-- <td><%= submission.prev_bird_exp %></td> -->
    <!-- <td><%= submission.optical_equipment %></td> -->
    <!-- <td><%= submission.references %></td> -->
    <!-- <td><%= submission.sub_recall %></td> -->
    <!-- <td><%= submission.guide_use %></td> -->
    <!-- <td><%= submission.unusual %></td> -->
    <!-- <td><%= submission.notes %></td> -->     
	<!-- <td><%= submission.admin_notes %></td> -->
    <!--<td><%= submission.working_notes %></td> -->
	
    <td><%= link_to_if(submission.user_authorized_to_view?(session[:user]), 'Show', submission){} %>
    <%= link_to_if(submission.user_authorized_to_edit?(session[:user]), 'Edit', edit_submission_path(submission)){} %>
    <%= link_to_if(submission.user_authorized_to_destroy?(session[:user]), 'Destroy', submission, confirm: 'Are you sure?', method: :delete){} %></td>
  </tr>
<% end %>
</table>

<br />
<%= will_paginate @submissions %>

<% end %>
<!-- %= link_to 'New Submission', new_submission_path % -->
